package com.example.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.SqlHelper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.example.mybatisplusdemo.entity.User;
import com.example.mybatisplusdemo.mapper.UserMapper;
import com.example.mybatisplusdemo.model.vo.UserVO;
import com.example.mybatisplusdemo.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * User 表数据服务层接口实现类
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


    @Override
    @Transactional
    public Page<User> complexBiz(Page page, User user) {
        EntityWrapper<User> ew = new EntityWrapper<>();
        baseMapper.insert(user);
        ew.in("age", new Integer[]{0, 2});
        ew.like("name", "三");
        return this.selectPage(page, ew);
    }

    @Override
    public List<UserVO> listWithRole() {
        return baseMapper.listWithRole();
    }

    @Override
    public List<User> listAll() {
        return baseMapper.listAll();
    }
}